added firebase support and refactored a bit
fix merge