Cleaned up some memory issues