Awesome refactor: passing functions around, file handling DRYer