Fixed tricky line drawing bug.
Implemented a more robust painter's algorithm with outlining and such.