Code cleanup & serial communication protocol