Rewrite this to be more compatible with mods