Added documentation and fixed minor style issues