Revert default category if it is deleted

Fixes #312
Check in the frontend whether the defaultCategory has been set before looping through all the categories