Added queue logic. Added some helper methods.