Suggestions for splitting up this file into chunks are welcome. I am still not quite comfortable with the required SWIG directives.