Refactor of input system