This is the same problem described in
this thread. It seems to be related to the order you do things in, but we haven't tracked down exactly what triggers it (if anyone knows, please tell us!)
In the meantime, there's a workaround suggested in that thread that might help you.