Reorganize themeSourceFolder determination logic