merged with current master
adjusted slightly to reflect the changes to NDData