Refactored Animation Viewer

Everything is more readable and logically organized. Removed globals