Cleaning up JSDoc.

Added types for @params and added [optional] syntax where appropriate.