Is it not possible to try filling gaps and move data to the start of the disk while refusing to increase the number of fragments of any file?
That's exactly what the program does. It only moves files when there is enough space and does not fragment files on purpose. The problem is caused by the Microsoft defragmentation API, which sometimes can fragment a file while moving it, for no apparant reason. If JkDefrag notices fragmentation then it will try moving the file again with another strategy. If that fails as well then it has no choice but to leave the file fragmented as it is. In other words, this is not a bug in JkDefrag, but a problem in the Microsoft defragmentation API.