Fixed runtime warnings caused by division by 0