took changes from v2.0 branch