Fix #166 #193 in memory adapter