Base.lua: simplify some overly complicated logic