reorganization and style improvements