Work on Scala, introduced type hierarchy and partial functions, and cleaned up the rest