Bugfix for min/maxdist, and removed junk