Improve documentation and typing