Phase correction fixed, code reshaped to apply more corrections.

The phase correction was applied only to a subset of bits! Because of an
offset error.

The detection code layout was modified a bit to make it simpler to
implement more corrections in the future. However only phase correction
is performed currently. Slope correction, or to compensate for the cycloid
effect are two possible improvements.