fixing distance field bugs

This fixes issue #107.