Added a lot of error checking code to the exported functions in the `base' subdir (not complete yet).