Type cast | type hint all function arguments.

Attempt to force correct types wherever appropriate.

Use type hinting for arrays in arguments. In other cases, cast to required
datatype before it is ever used.

In some situations, this will result in more errors, but it will be better
in the long run.
Merge branch 'import' into dev