Overhauled drawing code