Refactored rendering, added debug draw option to the ui