Refactored code for binary protocol (prepared statements).