Lots of bug fixing.