Small fixes

I came across few errors in the code when looking through the code.