Implement correct handling for decoration theme switches
Fix some memory errors