Refactoring element-drawing. Still buggy.