fixed a lot of type mismatch bugs, optimized code, re-enabled interrupt1 and compensated code accordingly, added a switch for serial debug to inverse interrupt 1 (serial-on, interrupt1-off and vice-versa) for memory and space reasons, added some introduction comments at the top.