Forgot to add all these 'function' declarations. Oops.
Was actually pretty much finished...