Change back to in-house flexbox implementation; fix Safari bugs