Some new functions, and some revisions to logic in existing functions.