Error checking, simplification, and removal of dumb cruft