If you hold command while you restore the window from the dock it will restore into the current space. I wish i knew how to make this the default. Getting whisked away to a random space is one of the most irritating issues. Like when you want a finder window for downloads and instead of a new window in the current space you get taken cross country to on thats already open.