Extracted main code. Fixed cabal file.