added preferencexml writing and some compiler fixes