Small optimizations & rafactoring.