The wing flipping at night, we experienced that with a parrot. Just the quick flick or two, but going on and on. I think it's always been because of an irritation. Either a feather cut too sharply and poking his side, or a feather growing in, or a feather coming out ... the flick is to snap the wing feathers back into place. Is your bird molting right now, or did he have a recent wing clip? There could be other reasons .. something itching the skin, or mites even.
Does he like baths? Sometimes a good soaking seems to wash irritating stuff off the body, and soften up the feathers, and clean them so the barbs zip together cleanly, and a bath always seemed to help with the flicking. The flicking used to come and go, and the aboveis just my impression of what was causing it.
If by perch thing you mean one of those "happy hut" jobs, take it out and throw it away! You would't BELIEVE how many posts there are here from people who lost birds to those things. People who said their birds loved them and never chewed them, and then one day the bird is on death's door because it's been secretly eating loose strings from the inside of the thing ... or they get a thread wrapped around a foot or toe and gangrene has set in by the time anyone sees it ... or they get their head caught in a loose thread and strangle, or hang by one leg until they die. Those things are terrible, awful, kill so many birds and they should not be on the market.