Refactor project into library and samples