Use a function to check the validity of a request id and sanitize it in various places. Fixes #48.