Resource refs

Added resource references, check for circular dependencies