Added more assertions and fixed format.