Fix dimension bugs