Switched to GNU readline library, which adds history functionaliy, arrow keys, etc. Fixed some other minor bugs