Addition of SmElement class/factory, associated refactoring.

This is unfinished; it doesn't really work.  Had to commit for the end
of the week.

As noted in comments, the low-level stuff is confusing the
responsibilities of the new SmElement class and should be moved into a
low-level Strategy.