Organized some functions a bit.