cleanup, helpers, contracts, and pinpointing bugs