Maintenance: added documentation and basic restructuring