a bit of clean-up and documentation added