generators/library: Restructure the code a little