Also minor refactoring to simplify code flow making it easier to understand Since we squash-merge all PRs, having the title conform to semantic PR guidelines is sufficient. We don't need to check the commits as well.