Fix inline comments and doc blocks.
More useful error messages in exceptions.
Avoid useless branching.