Use bigger buffer, and improve error handling