Correctly process `ttl` argument.
Add docs and comments.