Added commenting, explicitly return values in functions