code cleanup; added logging and scaladoc