Fixed db trucations, added debug code, and tested code integration