Fixing bug in is_empty() and indexing