javascript refactoring.
Close #115 - add length check to box creation.