some cleanup, error checking, timing, etc