clean up index task and templates
organize some code, add comments and additional attribution for Paul Armstrong's swig-extras