Major refactoring finished for now