Add pkg_version function and cleanup

Change-Id: I3a994ef94402f41c6ecef6063f5376b71a716583