Fix style
Simplify error handling
Add buffer file