Changed setting of properties and did some refactoring.