Animation fixes and code cleanup