Move legacy code out of init.lua