Fix service configuration

And reorganize files a bit into separate class libraries.