copied in existing functions and adding a few new.