Refactoring of scala_compile.py and related code.

It's much more readable now.

Auditors: markcc@foursquare.com.