Use Sbt transactional classfile writer

This PR brings the IDE in line with Sbt default behavior. A couple of cleanups on the way (see individual commits).
This PR is a rebased version of #670.

Fixed #1001953. /cc @gkossakowski