Refactoring box and slight code improvements