added save to file, some debugging

pretty much done