Add terminal plugin, and refactor