fix many problems in recent code pushed by jtlap: incorrect includes, bad formatting, wrong name of macros