Some theme refactoring.

Rebased pull request #17.