Massive code fix to get the codebase ready to compile in BYOND 500