Ilmakko is right about old pellets but probably not significant enough to cause your problem. Fresh pellets might help a bit. Any relatively high quality .177 pellet between 8 and 11 gr will get you started. As you get it more tuned up and are happy with it. THEN start experimenting with pellets to get your best one. There are literally about 100 different .177 pellets available. The golden rule is: subsonic (less than 1100f/s). - around 850-900f/s seems best for most guns. My .177 D54 likes the 10.6gr Kodiak Match best (not sure if it is still available) But K&N has one that is virtually identical and weighs around 10.5-6gr.) I did a study about 8 years ago with over 90 pellets in my D54 .177. Loose scope mount as you found is the issue. You need to be sure that the scope bases you are using have a retaining pin. The scope rail has two blind holes that are designed for that purpose. Get a scope base set that has a pin in at least one of the bases and put it in place. Don't over tighen the pin as at least one person has ripped the sight rail off the action (ruins the gun!!!). Just put the base in place and ensure the pin is in the hole. Tighten the base then snug the pin but don't over do it. While you are at it! If you have a torque wrench, tighten the bases to about 35in/lb torque. And remount the scope tightening the ring screws to about 15in/lb. If you don't have one... it is highly suggested and not terribly expensive to buy. Wheeler FAT wrench is just fine.
Looks like the screw that sits at the rear of the scope rail?