Add rake task to output and refactor