Merging in Ray's changes after testing