Refactor to be more easily useable as a module through bower