added nice logging, and fixed up things