Finished writing collapse functions.