First cut at collision detection; added doc strings to all functions.