more cleanup
finalizing some functions
split out sorting into sort_functions.php
testing