fixed a lot of bugs and now the datepicker works