Bug fix and VS warning fix