Input handleable middleware mostly working through copy paste.

Will refactor later.