More testing. Flexible sorting added.