Fixed errors and warnings reported by Visual Studio