Fixed seg fault bug that only appears on some terminal emulators
Corrected order of render/refresh/input functions in the main event loop. More bug fixes in the new line function - I think it's fine now. Also added some debugging functionality