changed threadprint() by fprint() and added a STACK enum, to avoid stack overflows.