Corrected geometry handling. Removed redundant arrow drawing code. Modified thresholding.