Misc updates and refactoring