Small atlas building fix.

Before there was a problem if the same animation appeared twice in one level
using different frames; this would cause the animation to be added to the atlas
twice.

In addition to fixing this problem, this change also unifies the name->frames
conversion from the two atlas building methods into one external funciton.
A few cosmetic changes.