Python detection updates

See commits for details.