This is an improvement and more than I could come up with.
However, I'm not entirely sure, but I still have the same objections to your "d" term in your new derivation. I think putting that in and not accounting for the gear ratio is tantamount to accepting the 180 degrees assumption.
Anyway, the spreadsheet will be done on monday. It will show the chainlength and gear inches of a gear choice, determine the number of gearings that would work with vertical dropouts of a given chainstay length, and provide all feasible 'flop' combinations with a given horizontal drop range and primary gearing choice. what fun!