Misc. refactoring