Added temporal wegihted query, fixed bugs