A couple cleanups and a stupid bug fix