Fix a variety of issues