Cleanup missing semicolons and localize vars