Some refactors on queue management