Added and solved GC (in scala). Note that it is messy as fuck because I
composed functions until it hurt. This needs a refactor.