Code cleanup on the terminal stuff