Added obstacles plus some refactoring.