Fix metadata service bugs