Refactoring / optimizations