Fix all the bugs

It should all work much better now.