Added sorting to saved calculations and fixed old code for new firebase