Adding various functions from previous master.

Custom functions,.