More cleanup, refactoring