Add docs, type signatures, use standard coding style.