major cleanup and bug fixes
Merge pull request #4 from KjeldJensen/master

Major cleanup and bug fixes