Fixed a bug where exclusive ranges were being generated incorrectly; added in a following key function that implements similar functionality to the Java implementation. Also updated relevant unit tests.