using spawn() instead of fork() (for rewrite branch)

same as #37 but for the 'rewrite' branch