fixes bugs, adds mono_logger to prevent "log writing failed. can't be called
from trap context" on exit