fix global leak, fix deprecated calls

See commit messages :-)