cleaned up maxDist from C-code