Some more improvements to shell script