Fixed thread count option; made cache entries only be created when needed; fixed some bugs.