Some improvements for working with terminal

Cleanup