Fixing var name style issues, fixing memory leak