God help me, I put aside a whole afternoon to figure this out.