Made some assertions more strict (does not change algorithm logic)