More reorganization and fix bug in previous commit