Fixed some unnecessary memory allocation