Cleaned up memory managment of c-allocated data