r7

Lots of bug fixes!