Memcached improvements

Various improvements for memcached (see commit)