Moved code around a little, and improved the Javadoc
Resolved merge conflict (I hope!)