MB-10268: Revise code to make it more clean

Change-Id: I2b379262ebd78eb47fd0575dab55788d2afd1d26
Reviewed-on: http://review.couchbase.org/36793
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>