Fixed swapping bug, not cleaned up yet