Fixed potential bugs when enabling plugins