Made more changes to the exntension with lots of refactoring