General refactoring, clean up.