Make RESTful operations return 404 Not Found when the target resource does not exist

In the original implementation, GET, DELETE and PUT operations on
non-existent resources used to return 500 instead of 404.
Thanks for your review.
I once closed this PR and opened #486.

Replacement of 404 was done in #486.