term.lua code cleanup