fixed entity relations to avoid exceptions on deletion of media with tags or media in galleries
update of gallery media views