Refactor rake tasks