Cleaned up configuration. Some refactoting.