Combined SOM with main executable

Moved SOM features and such to the main executable and added options and
things to handle SOM in main executable
bugfixes and refactoring