Fixed 511 gap filling function.