diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
index e98acf1..862bef6 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Parser.java
@@ -330,7 +330,8 @@
                     || Token.eq(")", t)
                     || Token.eq("]", t))
             {
-                if (needRedirArg) {
+                if (needRedirArg)
+                {
                     throw new EOFError(tz.line, tz.column, "Expected file name for redirection", "redir", "foo");
                 }
                 push(t);
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
index d3222f4..fc9bc67 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Pipe.java
@@ -25,7 +25,6 @@
 import java.io.InterruptedIOException;
 import java.io.PrintStream;
 import java.net.URI;
-import java.net.URL;
 import java.nio.ByteBuffer;
 import java.nio.channels.ByteChannel;
 import java.nio.channels.Channel;
@@ -39,7 +38,6 @@
 import java.nio.file.StandardOpenOption;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -49,10 +47,10 @@
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl;
 import org.apache.felix.gogo.api.Job;
 import org.apache.felix.gogo.api.Job.Status;
 import org.apache.felix.gogo.api.Process;
+import org.apache.felix.gogo.runtime.CommandSessionImpl.JobImpl;
 import org.apache.felix.gogo.runtime.Parser.Statement;
 import org.apache.felix.gogo.runtime.Pipe.Result;
 import org.apache.felix.service.command.Converter;
@@ -248,17 +246,23 @@
         try
         {
             List<Token> tokens = statement.redirections();
-            for (int i = 0; i < tokens.size(); i++) {
+            for (int i = 0; i < tokens.size(); i++)
+            {
                 Token t = tokens.get(i);
                 Matcher m;
-                if ((m = Pattern.compile("(?:([0-9])?|(&)?)>(>)?").matcher(t)).matches()) {
+                if ((m = Pattern.compile("(?:([0-9])?|(&)?)>(>)?").matcher(t)).matches())
+                {
                     int fd;
-                    if (m.group(1) != null) {
+                    if (m.group(1) != null)
+                    {
                         fd = Integer.parseInt(m.group(1));
                     }
-                    else if (m.group(2) != null) {
+                    else if (m.group(2) != null)
+                    {
                         fd = -1; // both 1 and 2
-                    } else {
+                    }
+                    else
+                    {
                         fd = 1;
                     }
                     boolean append = m.group(3) != null;
@@ -283,37 +287,45 @@
                         }
                     }
                 }
-                else if ((m = Pattern.compile("([0-9])?>&([0-9])").matcher(t)).matches()) {
+                else if ((m = Pattern.compile("([0-9])?>&([0-9])").matcher(t)).matches())
+                {
                     int fd0 = 1;
-                    if (m.group(1) != null) {
+                    if (m.group(1) != null)
+                    {
                         fd0 = Integer.parseInt(m.group(1));
                     }
                     int fd1 = Integer.parseInt(m.group(2));
-                    if (streams[fd0] != null && toclose[fd0]) {
+                    if (streams[fd0] != null && toclose[fd0])
+                    {
                         streams[fd0].close();
                     }
                     // If the stream has to be closed, close it when both streams are closed
-                    if (toclose[fd1]) {
+                    if (toclose[fd1])
+                    {
                         Channel channel = streams[fd1];
                         AtomicInteger references = new AtomicInteger();
                         streams[fd0] = new RefByteChannel(channel, references);
                         streams[fd1] = new RefByteChannel(channel, references);
                         toclose[fd0] = true;
                     }
-                    else {
+                    else
+                    {
                         streams[fd0] = streams[fd1];
                         toclose[fd0] = false;
                     }
                 }
-                else if ((m = Pattern.compile("([0-9])?<(>)?").matcher(t)).matches()) {
+                else if ((m = Pattern.compile("([0-9])?<(>)?").matcher(t)).matches())
+                {
                     int fd = 0;
-                    if (m.group(1) != null) {
+                    if (m.group(1) != null)
+                    {
                         fd = Integer.parseInt(m.group(1));
                     }
                     boolean output = m.group(2) != null;
                     Set<StandardOpenOption> options = new HashSet<>();
                     options.add(StandardOpenOption.READ);
-                    if (output) {
+                    if (output)
+                    {
                         options.add(StandardOpenOption.WRITE);
                         options.add(StandardOpenOption.CREATE);
                     }
@@ -348,65 +360,83 @@
             // the command is about to be executed.
             errChannel = (WritableByteChannel) streams[2];
 
-            if (threadIo != null) {
+            if (threadIo != null)
+            {
                 threadIo.setStreams(in, out, err);
             }
 
             Pipe previous = setCurrentPipe(this);
-            try {
+            try
+            {
                 Object result;
                 // Very special case for empty statements with redirection
-                if (statement.tokens().isEmpty() && toclose[0]) {
+                if (statement.tokens().isEmpty() && toclose[0])
+                {
                     ByteBuffer bb = ByteBuffer.allocate(1024);
-                    while (((ReadableByteChannel) streams[0]).read(bb) >= 0 || bb.position() != 0) {
+                    while (((ReadableByteChannel) streams[0]).read(bb) >= 0 || bb.position() != 0)
+                    {
                         bb.flip();
                         ((WritableByteChannel) streams[1]).write(bb);
                         bb.compact();
                     }
                     result = null;
-                } else {
+                }
+                else
+                {
                     result = closure.execute(statement);
                 }
                 // If an error has been set
-                if (error != 0) {
+                if (error != 0)
+                {
                     return new Result(error);
                 }
                 // We don't print the result if we're at the end of the pipe
-                if (result != null && !endOfPipe && !Boolean.FALSE.equals(closure.session().get(".FormatPipe"))) {
+                if (result != null && !endOfPipe && !Boolean.FALSE.equals(closure.session().get(".FormatPipe")))
+                {
                     out.println(closure.session().format(result, Converter.INSPECT));
                 }
                 return new Result(result);
 
-            } finally {
+            }
+            finally
+            {
                 setCurrentPipe(previous);
             }
         }
         catch (Exception e)
         {
             String msg = "gogo: " + e.getClass().getSimpleName() + ": " + e.getMessage() + "\n";
-            try {
+            try
+            {
                 errChannel.write(ByteBuffer.wrap(msg.getBytes()));
-            } catch (IOException ioe) {
+            }
+            catch (IOException ioe)
+            {
                 e.addSuppressed(ioe);
             }
             return new Result(e);
         }
         finally
         {
-            if (out != null) {
+            if (out != null)
+            {
                 out.flush();
             }
-            if (err != null) {
+            if (err != null)
+            {
                 err.flush();
             }
-            if (threadIo != null) {
+            if (threadIo != null)
+            {
                 threadIo.close();
             }
 
             try
             {
-                for (int i = 0; i < 10; i++) {
-                    if (toclose[i] && streams[i] != null) {
+                for (int i = 0; i < 10; i++)
+                {
+                    if (toclose[i] && streams[i] != null)
+                    {
                         streams[i].close();
                     }
                 }
@@ -472,11 +502,14 @@
         return null;
     }
 
-    private Channel wrap(Channel channel) {
-        if (channel == null) {
+    private Channel wrap(Channel channel)
+    {
+        if (channel == null)
+        {
             return null;
         }
-        if (channel instanceof MultiChannel) {
+        if (channel instanceof MultiChannel)
+        {
             return channel;
         }
         MultiChannel mch = new MultiChannel();
diff --git a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java
index 558b2d9..549cb5c 100644
--- a/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java
+++ b/gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java
@@ -108,11 +108,13 @@
                 case '<':
                     t = text.subSequence(start, index);
                     tn = text.subSequence(start, index + 1);
-                    if (redir.matcher(tn).matches()) {
+                    if (redir.matcher(tn).matches())
+                    {
                         getch();
                         break;
                     }
-                    if (redir.matcher(t).matches() && start < index - 1) {
+                    if (redir.matcher(t).matches() && start < index - 1)
+                    {
                         getch();
                     }
                     word = 0;
@@ -120,7 +122,8 @@
                 case '&':
                     // beginning of token
                     if (start == index - 1) {
-                        if (peek() == '&' || peek() == '>') {
+                        if (peek() == '&' || peek() == '>')
+                        {
                             getch();
                             getch();
                         }
@@ -128,16 +131,19 @@
                         return token(start);
                     }
                     // in the middle of a redirection
-                    else if (redir.matcher(text.subSequence(start, index)).matches()) {
+                    else if (redir.matcher(text.subSequence(start, index)).matches())
+                    {
                         getch();
                         break;
                     }
-                    else {
+                    else
+                    {
                         word = 0;
                         return token(start);
                     }
                 case '|':
-                    if (start == index - 1 && (peek() == '|' || peek() == '&')) {
+                    if (start == index - 1 && (peek() == '|' || peek() == '&'))
+                    {
                         getch();
                         getch();
                     }
diff --git a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
index 7980014..ec69734 100644
--- a/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
+++ b/gogo/runtime/src/test/java/org/apache/felix/gogo/runtime/TestParser4.java
@@ -65,7 +65,8 @@
     }
 
     @Test
-    public void testRedirInput() throws Exception {
+    public void testRedirInput() throws Exception
+    {
         Context c = new Context();
         c.addCommand("echo", this);
         c.addCommand("tac", this);
@@ -83,7 +84,8 @@
     }
 
     @Test
-    public void testMultiInput() throws Exception {
+    public void testMultiInput() throws Exception
+    {
         Context c = new Context();
         c.addCommand("echo", this);
         c.addCommand("tac", this);
