Removed unused variables and freshened up code