Rewrite fork/clone.

This is still a bit ugly, needs cleanup.
Fixes that weird GCC issue.