Terminal

Refactoring code style and fixes #40.