Refactored everything in lib to core to simplify things