Refactoring thread

Fair warning: this code is not intended to run just yet. As I was refactoring the functions I realized I had questions for Dan and Co. and decided to put them up on github in order to avoid another long email thread. I'll try to tag people in specific comments to make those salient to relevant folks.
@feenberg could you tell me more about the maximum foreign earned income variable and how we should be calculating it? I'm getting conflicting evidence from the SAS code and @SameerSarkar's python translation.