Refactored lib init