major library refactor