Improve documentation and type specs