reformatting in drawing.js, and some refactoring. Improving core.js