Added documentation, parameters and fixed a bug.