Fixes deadlocks with the monitor