Rewritten drawing code

Tidied up codebase