Add debug logging + more cleanup