General fixes

General fixes that @GICodeWarrior suggested, and some stuff I found while looking at the source code for more than 5 seconds.