Change the type of variables.

It looks like hash variables were defined as arrays.
Handle import error; add docstring in the Python way.