Upgrade packages.
Refactor and clean up