Better command registration. Fixes #3
Optimise some imports