Fixed some bugs in Firebase listener.