some tweaks and documentation added
cleaning up and commenting