Improve buffer parsing