Fix mkdir crash and use encoding detector for project import