rebuild gaps, added comments