Some logging
Fixed tons of little logic errors, typos, bytes/str issues