Replaced some classes with namedtuples + helper funcs, and simplified/hardened a bit UIDs generation.