Fix segfault when document's input is set before its language
Move StringInput into its own file