Minor refactor and added javadoc