Close console window when waiting key
Use LDT
Split api source files and make library to eliminate unused function