Move some functions to more appropriate place.
Change bool is_left to enum cp_type.