Added some asserts to narrow down #1685.