Extra credit almost done

Only one more function needs conversion to foldr or similar.