Updating code (fixing leaks) and docs.