Major refactoring
Very small optimization