Improved project structure and cabal file, fix small bugs, add haddock docs