code documentation and reorganization