For one you are spawning the entity even if it is null.
EntityLiving entityliving = spawn instanceof EntityLiving ? (EntityLiving)spawn : null;
spawn.setLocationAndAngles(pos.getX(), pos.getY()+1.25f, pos.getZ(), worldObj.rand.nextFloat() * 360.0F, 0.0F);
AnvilChunkLoader.spawnEntity(spawn, worldObj);