Initial commit based on the code taken from CLMM.