Use import instead of destructuring

This is a followup to 0ffc2c0c96542c5aa8766dbd79d2b7f1dbfc481a. By using import we get static error checking which found some minor bugs.