Fixed a few memory issues.