Still pretty much pseudo-code, but comments be helpful