Rework canonicalization
Make id generation deterministic