JavaDoc-ing and a bit of refactoring