Fixed DataModelReference and reference resolution. Command improvements.