Improved package detection