Bug fixes and improvements in pyshell