Fixed more collision bugs and optimized overall code.