Function module is *roughly* working. That is, it works on one test case. But I'm done for the night.