updating to latest version: cleanup and optimizations