Some bugfixes; added a method to check the current index