Threading finally works, definite improvement in efficiency