improve collision; add debug mode