Commented code a bit, removed unused variables/functions