Made code more readable, and updated documentation