Fixed PVS-Studio warnings

Fixed some warnings from PVS-Studio: http://www.viva64.com/en/b/0191/