refactors and BeanDefinition serializer