improved package parsing