Moved write/read logic to protected functions, for better extendability