Moved functions from .h to .c. Finished comments.