Updating some function implementations from the functions jep
Fixing sort and cleaning up validation