Fixed header sizing problem on mobile, refactored code