proper htons handling, added debug output for signals