Fixed logging/errorhandling