Add detailed debug messages, making names better, and fixing unit tests