work off FIXMEs, add some sanity checks, clean up