Update most of the API to use pointers instead of references.  Fix segfaults by properly initializing all data.