fix incorrect self pointer that causes crash when writing to stdout