Added support for multiple bases and tests for lazy sorting.