Don't refer to globals, use locals instead, and handle RTD_NEW_THEME = False sanely
Merge pull request #495 from alex/patch-1

Don't refer to globals, use locals instead, and handle RTD_NEW_THEME = F...