Remove obsolete imports.
Self-tests for regex matching.

Also tighten exception handling around file opening.
Autocommit: libraries changed 2014-06-20-10:44:33