Improves comments and reorders functions
More tests