some bugfixes in sync function