Adding documentation and minor fixes