Refactor Firebase structure