Further refactoring of common code for producing request bodies. Also refactor bucket and object listing to use new common code.