Minor changes

I have made some minor bug fixes / changes that I have found while reading the code.