Fixed some memory issues.