general cleanup, and added documentation