Refit schema to structure. Other minor improvements