bug fixes for inserting into top of queue