[FIX] Fixed empty index bugs.

I know about the TODOs but for consistency with the master branch I would leave them in here in this commit.