kernel: better managment of stacks for processes

The way the directory table was being copied in the event of a fork() left the
stacks of the forker with a higher refcount that they should, so they never got
released. This somewhat of a hack fixes the issue. Now all memory leaks seem to
be gone.