rc.lua refactoring