add application and extraction of the 'flatten' transformation (without context)
add context to flatten, with some refactoring
add promote transformation, with bug fixes and refactoring