Introduce theme middleware and functions