Fixed some segfaulting. May be working OKish now.