DX code added. Code is far from perfect. Will change later.