Update documentation, remove redundent functions and other code cleanup