move requires to top, clean up comments
major restructuring for purpose of error checking

don't allow CIs unless it makes sense