added some asserts after callocs