Added ldoc generation to build and fixed poor documentation in code