You should start with a new implementation of this gallery in its default state. It seems that you may have removed too much stuff to allow it to work. You should start fresh again and when you are altering parts of it test it out one step at a time to ensure that you are not loosing any of the functionality.