Improve type checking

This PR turns up the compiler another notch, and adds more jsdoc-style comments to increase the amount of type checking.