Add documentation and harden code.