still working..

Switched the linked lists around a bit since the old version segfaulted and stuff.
I feel this solution works better..