Clean up the delegate and debug output a bit