First bug fixes, ready for test.