Restful manager

Alleviate the code bloat in `restful.module` by organizing code a little bit better.

This PR only moves code around, no new features to see.