Clean up code by using a flatten and fix an Anal type.