Minor improvements. Some code refactoring, docs, etc.