Refactor analyze of functions and ctors to remove code duplication