Found some stupid memory errors with Valgrind. Thanks, Valgrind.