Fixed some bug so the Sample2D can work.