Major refactoring

 - Change syntax for declaring sorted sets
 - Move common SortedSet methods to a module
Properly encode range query
Fix tests