Added automatic logging of exceptions
Added check for filename length