All that resource api stuff.
A couple resource-related bugs.