some core lib refactoring