this is the two-pass validation patch; it seems to almost work right
the debugs are increasingly hard to read... must colorize