Massive refactoring

This is a massive refactoring. Removed console.ts and wrote a terminal emulator in terminal.ts. 

This is a breaking change. Reverts some issues.

Fixes #8. Fixes #4.