Removed unnecessary calculations
Fixed all compiler warnings