fixes from @MalcolmEvershed