Added asserts after mallocs