proper comments,
fixed some bugs with scaling when brushing;
put everything in a IEFE