Added percential method.

Also cleaned up imports, added comments, cleaned up comments.