Fix while loop. Additional (unfinished) work on macros/defs.