seems to work, but not tested a lot, and still a lot of debug messages