Moving functions to core.lua