core: put more intelligence into queue_msg()