Somewhat flawed compareTo implementation.
Also some bugfixes and convenience methods.