Fix crashing bugs when there's no data