Reorganization, documentation and cleanup