Updated to manifest v2
Refactored some code