Animation functionality added

Additionally done some refactoring.