Renamed some functions, added some comments.