Final cleaning & refactoring