Fixed many collision bugs, fixed memory error when closing.