genlist: Refactoring genlist codes.
<Comment by SeoZ>
This is a partial commit of D788.
As D788 is huge patch and genlist is really fragile, I decided to
split this patch and it was partially done on the airplane during
my business trip last month. As I had no solid amount of time to
finish that job after that trip, I decided to push existing patches
first. I will finish this job soon. Sorry bluezery.
But I will keep your credit on the merge commit. Please make an
atomic patch next time. You can do it.