some reorganization, documentation, simplification...