Misc. refactoring.