Bug squashing across most of the scripts.

I thought I should do a bit of work on the script and commit something
for my one year on GitHub. Happy one year on GitHub to me!

If you notice any other bugs please open an issue.