A bunch of functions I wrote for the course (there may be a couple of bugs left)