added some memory allocation stuff