Bug fixes and comments

Bug fix for exiting regions.
Bug fix for internal transitions.
Many comments.