quite a bit of integer theory going through. Need to deal with theorems next..