Avoiding possible global variable definitions and adding missing semicolons