Change drawing algorithm

Update drawing algorithm to recursive depth-first and fix many
problems with parsing.