Added documentation and small improvements