more assertion errors and bug fixes