Even more epic refactoring and code cleanup...