Fix some memory issues.