Fixed a couple of wanrings related to shmdt and added stack size check to system.