improved theme handling