speed increase and fixes