memory-related bugfixes