add a period.
Try to improve error reporting

- Also add some doc comments to the code
- fix a bug in target_version setting