WIP: Refactor script out of rake