fix bugs and change some structure level things