Making align_ungapped match the corresponding code in Po-Ru's C++ version