Fixes 'undefined index' and 'division by zero' notices.