Merged/added some stuff from MinOZW