Cleanup unneeded tmp vars. Now keeps track of line number for error reporting.