Some small refactoring and improvements
Corrections to box types halfway done