Less stupid memory management

Changed all pointers to shared_pointers. Had a senior moment about
those. Either way, now there's absolutely no manual memory management.