Improved pext implementation in software suggested by Gerd Isenberg.