Major refactoring done and everything still works.