Massive refactor and repackage