Add documentation and make some stylist changes to the code