Added fixes from Greg Allen.