Bug fixes
More bug fixes, it should work fine now.
Note input is taken from a buffer using curses
instead of a simple loop.