More fixes and reorganization