Added documentation and fixed a minor issue