add logging, cleanup