Added circular reference check
clean up