added a few documentation/refactored