Shell.terminate() changed
some trycatchs fixed
Exceptions fixed
Corrections after Andrey and Radim's review