Major refactoring of class struture and gen_for001