diff --git a/xcpt.c b/xcpt.c
index ab529cd8426d34334a3fffcd925c3c06f066451b..708ad34820f3b1ab72c596270cd9d669bbc732a2 100644
--- a/xcpt.c
+++ b/xcpt.c
@@ -92,7 +92,9 @@ static char *xstrdup(const char *x)
 	O(MEDIAYSIZE, "29700") \
 	O(FINISH_STAPLE, "") \
 	O(FINISH_PUNCH, "") \
-	O(FINISH_FOLD, "")
+	O(FINISH_FOLD, "") \
+	O(FEED_ORIENTATION, "automatic") \
+	O(QUALITY, "standard")
 
 enum option {
 #define O(name, val) OPT_##name,
@@ -206,7 +208,7 @@ static void parse_pjl(void)
 	    bug("PJL error: Line too long");
 	  line[i++] = c;
 	}
-      while (i > 0 && (line[i] == ' ' || line[i] == '\t'))
+      while (i > 0 && (line[i-1] == ' ' || line[i-1] == '\t'))
 	i--;
       line[i] = 0;
 
@@ -406,20 +408,10 @@ static void gen_job_template(void)
   if (OPT_IS_SET(ORIENTATION))
     xcpt_keyword("document-reading-orientation", OPT(ORIENTATION));
 
-  /*
-   *  Values used:
-   *
-   *	20 = 1 staple
-   *	29 = 2 staples
-   *	40 = 4 staples
-   *	90+94 = 2-hole punch
-   *	92+93 = 4-hole punch
-   *	110 = fold & staple
-   *	111 = fold only
-   *	113 = fold & swap sides
-   *	1003 = single-fold inside
-   *	1004 = single-fold outside
-   */
+  // XCPT specs allow feed-orientation either globaly, or inside media-col.
+  // The latter makes more sense, but it does not work on the WC7845.
+  xcpt_keyword("feed-orientation", OPT(FEED_ORIENTATION));
+
   xcpt_set_open("finishings");
   if (OPT_IS_SET(FINISH_FOLD))
     gen_finishings(OPT(FINISH_FOLD));
@@ -469,7 +461,7 @@ static void gen_job_template(void)
       xcpt_close();
     xcpt_keyword("media-type", OPT(MEDIATYPE));
     xcpt_close();
-  xcpt_keyword("print-quality-level", "standard");	// FIXME: standard / enhanced / highest-resolution / toner-saver
+  xcpt_keyword("print-quality-level", OPT(QUALITY));
   xcpt_keyword("sides", OPT(SIDES));
   xcpt_close();