Fix uid handling and other errors