Fixed missing semicolons & global variables & unused variables