Fix uid pointer handling and debug messages.