More cleanups / reworks and refactoring into classes