Turns out that there were some stupidly subtle bugs (RMS being the wrong way around, pow not working the same as **, off-by-one indexing, etc). Still not confirmed but here for sanity.