Re-do several lost fixes in restbase module

A merge conflict in a git stash pop apparently lost most of the original fixes
in this patch, so re-do them here. This is a follow-up to 3cbb1eba8ab8d, and
adresses Alex's review comments there.

Change-Id: I55a63b60a606d13ba4f201d3cc5b9b22d793c0f6