restore changes to lib.js from commit 4b8e9b3
restore custom header support from commit 25a64d2
restore commit ae9f867
restore commit 35d2437
restore commit to JS from f5e0c89