Fixed bug in algorithm. Extended GUI controls.