Added functionality for animated sprites / refactored a little bit