piece data handling updates: added write buffer, fixed code in setData to avoid redundant isValid calls, use buffered data for validation when available