Added, fixed and updated JavaDoc.

Also fixed code layout / style in some classes.