Add documentation and improve PEP8 compliance