some swapping optimisation
cpu/gpu threading
some small fixes on gpu