Code reorganization and documentation

No improvement in functionality