Reworked documentation, reformatted the code, changed some code lines