Modified algorithm, fixed some small details and added javadoc to Stroke.java.