Fixed typo

Mostly cosmetic changes to code.
Fixed typo in s calculation.