Better exception handling
Replaced prints for logging calls