Refactoring more into /lib/core