Also clean up theme selection code to get rid of duplication. Change-Id: Idf7b21db70ee83fce24756ead877169bd08b77a9