Fix bash script issues

Fix #354 and fix #353