fixes from Dan, after review