backported all the changes required for Firebase to work. The architecture is now much better indeed