some refactoring for spray-json support and others