cleaned up debug, improved comments