added documentation, some small improvements