Resolves issue #83

Just took manubo's and mmoya's fixes from the issue comments and added them to a patch file. Add a line to the shell script to apply the patch.