fixing middleware and cleaning up conventions