Reduced code and improved unique id generation