more comments, cleanup, and fixed a small bug with how preconditions are checked.