Modified some printing logic and rewrote all JavaDoc comments.