Changed State to an interface, and a bunch of misc code fixes and
javadoc tweaks.