More refactoring of api uri building code.