Redone the code layout of main.js and fixed the pencilcolor initialization