Fixed lag not undoing itself, fixed memory leak

Not closing a scanner causes a memory leak, and that will no longer
happen