Some basic code cleanup. Also, an optimization during line callbacks to
dramatically increase speed.