Fixed some memory problems.