Added asserts for mallocs