thread.c: added support for optional user provided stack allocator
wkspace.c: made initialization routine a regular subroutine