Modified the threashold-based trimming of the surface as it was missing some points due to round off error.