Added documentation
Refactored (C) extension code