Cleaned up and restructured