Cleanup + refactoring