Abstracted a lot of drawing code and fixed invalid context warnings