Add debug logging
Add helper for casting