[BUGFIX] Reorganizes code for better cleanup

Close open comment on last line and other possible hiccups.
Do this by inserting a final semicolon. This may look ugly,
but we also insert one at the beginning, which is because
of our streaming implementation. These semicolons will make
the result very robust to include/merge with other files.
If you dont like them, you can remove them with substr.
Maybe add command line switches to adjust the behavior.