More work on fixing line numbering and also fixed a memory error in run_current_cmd (also improving performance in the process)