Move some code around. Re-add thread-stack-size