FIX: Firebase issues

This should run now, but it still has problems you should debug on your own. 

Read all the code that's changed in this pull request by clicking files changed and commenting where you have questions. 

After you understand what changed, you can merge the pull request.