Implement text input
Fix a bunch of bugs