Changed new and delete to malloc and free