implement feedback from pull #1044

- delay object creation for performance reasons
- use core library methods for parsing url/path
- fix http response code (500 => 404)
- eliminate `that = this` usage by closing over prefix variables directly