some formatting changes and small refactorings
improve algorithm for generating uuids