Large refactoring
Inner classes moved to outer classes
Converting to API v0.9 and Scala 2.10