Code cleanup and JavaDoc