Forgot to commit a small tweak to the previous fix, simply changing order of when the z-value is changed and when things are drawn