after the suppression of the bavarian soviet republic , he took part in `` national thinking '' courses organized by the education and propaganda department ( dept ib/p ) of the bavarian reichswehr group , headquarters 4 under captain karl mayr , whose main goal was to identify and remove threats to the reich .