Wholescale refactoring
Add tests
Reorginze platform dependent threading / timing code
and many other subtle changes