copied from the root of ms013g