Code cleanup

Moved various functions into the pellet class.