Fixed several bugs, found a couple of new.