fixes ordering problem, and fixes dates to be stored as longs, so they are sortable