Major refactor, javadoc, optimization, all teh things.