Reworked input handling