Sphinx template cleanup

Cleaning up the code for @Carreau since I wan't expecting it to be merged in so soon.