Changed use of DateTime and improved some queries.