Fixed null pointer deref bug.