Some refinements.

1. Add docstrings.
2. Re-implement get_deep_extends().
3. Remove all inners.