Improve request id generation. Closes #2040