Fix bugs and add docstrings.
Fix 0-angle bug.