Fixed nasty null pointer bug

masqeurading as a deadlock