Some fixes, tests passing