Improved input handling as well as some other fixes.