ui: Improve id management

Id is now a separate typedef, and the id generator uses an (optional) context hash