Fixed segfaults.  I remember why I dislike C++ now.