Refactored the rake tasks