Fixing malloc' issues and dynamic kthreads array