Fixed some circular reference and 'null' issues