Made input handling threaded
A couple of other changes