Added main activity, some refactoring.