MAssive update - should have commited more often - but consider this to
be the first fully working version.