Abstracted two blocks of code in Query_Builder.extend() into separate functions.