Fix some bugs, including an issue with overenthusiastic inlining of variables.