Add part of frostsnow's p3-2.