Move function helpers into their own directory and add degree reversal