Reorgs class hierarchy. Adds annotation, image_resource, resource and service. Fixes to_json.