Refactor of purge-branches, make it better