Fixed crash on shutdown and silly mistakes.