Major refactoring of query queueing mechanism, protocol packets, buffer parsers. Added new minor features.

Major refactoring of query queueing mechanism, protocol packets, buffer parsers. Added new minor features.