Added JavaDoc. Cleaned up code.