expansion.cpp: minor changes (logging, ifdefs)

- print format modifier changes
- one const fix
- moved ifdefs guards ouside functions (simpler, and no warnings about unused functions