Fixed various small bugs causing crashes in a number of modules.