Some cleanup and added documentation