Conversion to R package, further optimized threshold determination for slope unit size, other minor bug fixes.