JAL-1827 refactored to handle missing residues better