Fix a range of issues