added more comments for the internal queue data structure; also introduced some minor optimizations. thanks Shuxin for the patch.