Fix segmentation fault.

Happened when moving code around. I should've tested more...