generate stun responses and clean up some code mess