Improving logging

Removed debugging code, improving error logging