Ported also to local-memory version.