Remove auto inserted newlines at eof
Move variable declaration to top of scope
Fix preamble for externals