Some code cleanup

Here I've created an Eclipse project and used the IDE's capabilities to remove copied portions of code and make it more object-oriented.
I've corrected a tiny bug (comparing to an empty string), the rest of the functionality should be untouched, as I've tried to use automated edition to the greatest extent possible.
Please consider a note (FIXME) I've left in Pipe.java. These two methods were on original two copied portions of code, differing by two lines only.