Threading and various configuration fixes