diff --git a/libs/evoral/evoral/Range.hpp b/libs/evoral/evoral/Range.hpp
index 02d9210..abd119d 100644
--- a/libs/evoral/evoral/Range.hpp
+++ b/libs/evoral/evoral/Range.hpp
@@ -40,7 +40,7 @@ OverlapType coverage (T sa, T ea, T sb, T eb) {
 	   of A and B for each OverlapType.
 
 	   Notes:
-	      Internal: the start points cannot coincide
+	      Internal: the start and end points cannot coincide
 	      External: the start and end points can coincide
 	      Start: end points can coincide
 	      End: start points can coincide
@@ -53,13 +53,14 @@ OverlapType coverage (T sa, T ea, T sb, T eb) {
 	     |--------------------|   A
 	          |------|            B
 	        |-----------------|   B
+	     |----------------|       B
 
 
              "B is internal to A"
 
 	*/
 
-	if ((sb > sa) && (eb <= ea)) {
+	if (((sb > sa) && (eb <= ea)) || ((sb == sa) && (eb < ea))) {
 		return OverlapInternal;
 	}
 
@@ -73,7 +74,7 @@ OverlapType coverage (T sa, T ea, T sb, T eb) {
 
 	*/
 
-	if ((eb >= sa) && (eb <= ea)) {
+	if ((eb >= sa) && (eb <= ea) && (sb < sa)) {
 		return OverlapStart;
 	}
 	/*
@@ -85,11 +86,11 @@ OverlapType coverage (T sa, T ea, T sb, T eb) {
             "B overlaps the end of A"
 
 	*/
-	if ((sb > sa) && (sb <= ea)) {
+	if ((sb > sa) && (sb <= ea) && (eb > ea)) {
 		return OverlapEnd;
 	}
 	/*
-	     |--------------------|     A
+	     |--------------------|    A
 	   --------------------------  B
 	     |-----------------------  B
 	    ----------------------|    B
@@ -198,14 +199,13 @@ RangeList<T> subtract (Range<T> range, RangeList<T> sub)
 	/* The basic idea here is to keep a list of the result ranges, and subtract
 	   the bits of `sub' from them one by one.
 	*/
+
+	/* Here's where we'll put the new current result after subtracting *i from it */
+	RangeList<T> new_result;
+	typename RangeList<T>::List r = result.get ();
 	
 	for (typename RangeList<T>::List::const_iterator i = s.begin(); i != s.end(); ++i) {
 
-		/* Here's where we'll put the new current result after subtracting *i from it */
-		RangeList<T> new_result;
-
-		typename RangeList<T>::List r = result.get ();
-
 		/* Work on all parts of the current result using this range *i */
 		for (typename RangeList<T>::List::const_iterator j = r.begin(); j != r.end(); ++j) {
 
@@ -220,16 +220,16 @@ RangeList<T> subtract (Range<T> range, RangeList<T> sub)
 				/* Internal overlap of the thing we're subtracting from this bit of the result,
 				   so we might end up with two bits left over.
 				*/
-				if (j->from < (i->from - 1)) {
+				if (j->from < i->from) {
 					new_result.add (Range<T> (j->from, i->from - 1));
 				}
-				if (j->to != i->to) {
-					new_result.add (Range<T> (i->to, j->to));
+				if (j->to > i->to) {
+					new_result.add (Range<T> (i->to + 1, j->to));
 				}
 				break;
 			case OverlapStart:
 				/* The bit we're subtracting overlaps the start of the bit of the result */
-				new_result.add (Range<T> (i->to, j->to - 1));
+				new_result.add (Range<T> (i->to, j->to));
 				break;
 			case OverlapEnd:
 				/* The bit we're subtracting overlaps the end of the bit of the result */
diff --git a/libs/evoral/src/Curve.cpp b/libs/evoral/src/Curve.cpp
index 6f3532f..7491bab 100644
--- a/libs/evoral/src/Curve.cpp
+++ b/libs/evoral/src/Curve.cpp
@@ -301,14 +301,11 @@ Curve::_get_vector (double x0, double x1, float *vec, int32_t veclen)
 		if (veclen > 1) {
 			dx_num = hx - lx;
 			dx_den = veclen - 1;
-		}
-
-		if (veclen > 1) {
 			for (int i = 0; i < veclen; ++i) {
 				vec[i] = (lx * (m_num / m_den) + m_num * i * dx_num / (m_den * dx_den)) + c;
 			}
 		} else {
-			vec[0] = lx;
+			vec[0] = lx * (m_num / m_den) + c;
 		}
 
 		return;
