Bug fixes to gapfilling