there is no point in trying to open a non-existing box before trying to create it.
split header and move some code to more logical places.