Fixed several null pointer exceptions from bad attempts to index into
hashmaps, and where VariableFields were assumed to exist but don't
always exist.