Fix scopes and remove logging