Fix logic bug in optimizer, and fix up DEBUG_DEPS compile.