Fix a lot of little bugs