Scalaxy/JS: moved code around