Various fixes including date calculation