Fix various problems