Add SAN interface, code cleanups.
Move implementation-specific stuff to a nominal module.