Fixed Resource and Survey Services; Changed ObjectService

Refactored the ResourceService to be much smaller, and fixed small issues in the survey service.

Changed ObjectService by adding optimization for generateObjectID(). Optimizations include: (1) Reducing the number of object allocations and (2) Moved database queries to outside of the while loop.