adds better docs and fixes comments in the code