Adding documentation, cleaning extra functions and fixing issues