Refactor theme related functions.