Refactoring: suggestions from hlint and removing dangerous pattern matches.