Optimize uid saving