Fix shift-overflow warnings.
Fix implicit-function-declaration warnings.
Note about x_calc_ratio.