Fixes in date calculation