Fix some mistakes in asserts and log handling.