Improve queue and a few fixes