split keyboard & mouse codes to seperate files, and add memory management