Refactory light-core.js