Corrected inaccuracies in the calculations
Removed variable
Further implemented SQL mode
Corrected warnings