better catching and fixing shm cases