Some bash script improvements