Quadtree implementation and broadphase collision detection