Cleaner code; still segfaulting.