added comments and minor optimizations to thing rendering