Changed synchronized methods to synchronized blocks.