Adding Typechecks and improving middleware objects APIS