Fixes. Modified for adding proper logging statements and follow standards.