fixed some hashing, added polynomial(), and rewrote parts of extension logic