Fix a few bugs, remove a few (but not most) debug statements.