Fix java concurency issues