Fixed several errors, including a DIVISION BY ZERO caused by tommas