Changes requested in review:

1) More (and better) documentation
2) Remove typedefs
3) Change sign() to SIGN()
4) Several other formatting and minor changes