Lots of cleanup. Added back missing do -> block, fixed tests