Merged from Andrei, fixed conflicts