Refactoring of CouchBase command system