Fix a lot a bugs