fix a bug in the date parsing, some reorganizing