Resource refs

Added support for resource references, check circular dependencies