Graphics engine bug fixes