Misc revisions

Part of a massive refactoring to improve and simplify the project