split to core and lib. implement backends.