First try
Merge pull request #1 from kiu/master

Some refactoring.  Loses some functionality.