Some bug fixes for sync up

fixed some hidden bugs.