Added some error conditions, fixed bug when creating new todo