various bugfixes and add get_event_query template tag