fix bugs in error logging and write documentation about it