Updates from mingrody and rework to get proper sequencing with the functions.