Memcached improvements

Various improvements for memcached (refer to commit)