Fixed missing field assignment reported in SF bug #41 by Al, some other cleanups too