Revert "begin removing non flattened code"

This reverts commit 1d07c47fd06ed3481b8451d6b02cd46c5409817b.