fix bug in taggings join creation and clean up code