More cleanup&refactoring