Improve middleware handling, set up root URL and response