BUG: Improve empty dataframe handling