Minor bug fixes, ready for testing