Added asserts to each malloc