Fix multiple bugs in the input handling for the Python bindings