Fixed some key handling issues in the bash scripts.