Refactoring in resource functions, favoiring nested def's over use of
separate private def's
Updating API documentation.