code sync and some minor tweak