some fixes from ian work