Correct errorhandling
Reduce delays
Remove unused macro
Get rid of temporary variable