Some refactoring to reduce complexity for box validity.  #170
More refactoring, think it's in good shape now.  #170
Merge branch 'issue170' into devel