Fix drawing order

Closes #1594