Rearrange the library structure and implement some affine transformations