Added JavaDoc and converted all methods to have single return point