Fixed Division by 0 when minimizing window

This fixes an issue where minimizing the windows in Windows 7/8 crashes the game.  The problem with the piece of code is division by 0, which the added checks prevent.  Should resolve issue #126