Critical bug fix

Unsurprisingly, dereferencing a NULL pointer was causing weird glitches.