A little internal refactoring and performance