null jQuery fix, some loop optimizations