fix binary read/write
add debug stack