Added support for inserting middleware closes #14