Added JavaDoc and better output generation