Several bug fixes and renderer improvements