More cleanups / tweaks and refactoring