Refactoring of scala_compile.py and related code.

Auditors: markcc