Fix bugs in getHighestId(), getAllTasks(), and getAllEvents()