test for generateId. 
and a bunch of other random changes. 
Still coding like a squirrel.
mostly done ..I think.. but messy and buggy and not properly tested...
mostly done.. I think.. but probably not well written and probably buggy
and not properly tested.. :(