Significant clean-up of structure code