code duplication with putKeyValueCommand. I don't think the key should ever be null though.