Fixed some bugs. Found another. (Not very specific.) Mostly typos and
forgetting to use short-circuiting in my if-statements.