added synchronized to a few places

still not sure how it works, apparently isn't very much.