Fixed some bugs in rendering