Decompose genApply() in several smaller methods.