Code

Don't discard first point in pencil's freehand mode, and add a missing return statement