REST Security Updates and General Improvements

Commit message for details.
Sorry for the rather large single commit.